/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	///  逻辑服通知Game战斗结束
	/// module : structs_internal
	/// </summary>
	public class NotifyBattleEndPOD : IPOD 
    {
        public readonly static Func<NotifyBattleEndPOD> FACTORY = () => new NotifyBattleEndPOD();
		public static Func<NotifyBattleEndPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public long battleId;
		/// <summary>
        /// 
        /// </summary>
		public long pid;
		/// <summary>
        ///  战斗结果，不包含统计数据
        /// </summary>
		public BattleEndPOD resultData;
		/// <summary>
        ///  全部统计数据，上层分流
        /// </summary>
		public BattleStatisticsPOD statisticsPOD;
		
		
		
		/*-- constructors --*/
		public NotifyBattleEndPOD() {}
		public NotifyBattleEndPOD(long battleId, long pid, BattleEndPOD resultData, BattleStatisticsPOD statisticsPOD) {
			this.battleId = battleId;
			this.pid = pid;
			this.resultData = resultData;
			this.statisticsPOD = statisticsPOD;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_long(battleId);
            _out.Write_long(pid);
            _out.Write_pod(resultData);
            _out.Write_pod(statisticsPOD);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            battleId = _in.Read_long();
            if(!_in.HasRemaining()) return;
            pid = _in.Read_long();
            if(!_in.HasRemaining()) return;
            resultData = _in.Read_pod<BattleEndPOD>(BattleEndPOD.DynamicFactory);
            if(!_in.HasRemaining()) return;
            statisticsPOD = _in.Read_pod<BattleStatisticsPOD>(BattleStatisticsPOD.DynamicFactory);
        }
		
		public NotifyBattleEndPOD Clone() {
            NotifyBattleEndPOD o = DynamicFactory();
            o.battleId = battleId;
            o.pid = pid;
            if (resultData != null) {
                o.resultData = resultData.Clone();
            }
            if (statisticsPOD != null) {
                o.statisticsPOD = statisticsPOD.Clone();
            }
            return o;
        }
        
        public void Clear() {
            battleId = default;
            pid = default;
            resultData = default;
            statisticsPOD = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "NotifyBattleEndPOD [";
			str += "battleId=";
			str += battleId;
			str += ", pid=";
			str += pid;
			str += ", resultData=";
			str += resultData;
			str += ", statisticsPOD=";
			str += statisticsPOD;
			str += "]";
			return str;
		}
		
	}
}